package com.baobao.knife4j.controller;

import com.baobao.knife4j.pojo.User;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.Map;

/**
 * @author baobao
 * @create 2021-09-25 10:16
 * @description
 */
@RestController
@RequestMapping("controller1")
@Api(tags = "应用1-Controller1")
@ApiSupport(author = "baobao111", order = 1)
public class Controller1 {
    @GetMapping("api1/{id}")
    @ApiOperation("api1")
    public void api1(@PathVariable("id") @ApiParam("用户id") Long id) {

    }

    @ApiOperationSupport(author = "baobao222", order = 1)
    @PostMapping("api2")
    @ApiOperation("api2")
    public void api2(@RequestBody User user) {

    }

    @PostMapping("addUser")
    @ApiOperation("添加用户")
    @ApiOperationSupport(ignoreParameters = "id")
    public void addUser(User user) {

    }

    @PostMapping("addUser2")
    @ApiOperation("添加用户2")
    @ApiOperationSupport(ignoreParameters = {"user.id", "user.age"})
    public void addUser2(@RequestBody User user) {

    }

    @PostMapping("login")
    @ApiOperation("登录")
    public Map<String, Object> login() {
        Map<String, Object> result = new HashMap<>(2);
        result.put("success", true);
        result.put("token", "1364564646");
        return result;
    }
}
